package com.ilink.ilinkuser.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ilink.ilinkcommon.domain.DTO.UserAuthenticationRequest;
import com.ilink.ilinkcommon.domain.PO.userService.UserProjectParticipation;
import com.ilink.ilinkcommon.domain.R;
import com.ilink.ilinkcommon.domain.User;
import com.ilink.ilinkcommon.domain.VO.UserAuthenticationResponse;
import com.ilink.ilinkuser.domain.VO.UserMetaResponse;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

/**
 * <h3>new-ilink-java-backend</h3>
 *
 * @author LiuZheng
 * @description <p>用户信息服务类</p>
 * @date 2024-09-15 11:32
 **/

public interface UserService extends IService<User> {

    UserMetaResponse getUserMetaById(String userId);

    UserAuthenticationResponse getUserAuthenticationById(String userId);
    
    String uploadUserImage(MultipartFile file, String userId);
    
    boolean checkUsernameAndPassword(String username, String password);
        
    //更新用户信息数据
    boolean updateUserMetaById(String userId, UserAuthenticationRequest userMetaResponse);

    void createUser(User user);

    User loadUserByUserId(String userId);

    R updateUserImageById(User user, MultipartFile userCover, MultipartFile userImage);

    void changePassword(String userId, String oldPassword, String newPassword);

    Map<String, Object> generateTokens(String userId);

    void setTokenCookies(HttpServletResponse response, Map<String, Object> tokens);

    User loadUserByUsername(String username);

    boolean userExists(String username);
    
    String checkPasswordStrength(String password);

    boolean updateUserMetaByFile(MultipartFile file);
}









//public boolean updateUserMetaById(String userId, UserAuthenticationRequest userMetaResponse) {
//    User user = userMapper.selectById(userId);
//    //写入用户个人信息:这里不更新封面和头像
//    user.setNickname(userMetaResponse.getNickName());
//    user.setSex(userMetaResponse.getSex());
//    user.setUserIntroduction(userMetaResponse.getUserIntroduction());
//
//    //写入用户认证信息
//    user.setRealname(userMetaResponse.getRealname());
//    user.setSchoolName(userMetaResponse.getSchool());
//    user.setUserCollege(userMetaResponse.getCollege());
//    user.setUserMajor(userMetaResponse.getMajor());
//    user.setSchoolId(userMetaResponse.getStudentId());
//    user.setUserMobile(userMetaResponse.getPhoneNumber());
//    user.setEmail(userMetaResponse.getEmail());
//    user.setUserCampus(userMetaResponse.getCampus());
//    user.setStudentStatus(userMetaResponse.getStudentStatus());
//    user.setEnrollmentYear(userMetaResponse.getEnrollmentYear());
//    //写入项目参与情况
//    UserProjectParticipation userProjectParticipation = userProjectParticipationMapper.selectOne(new LambdaQueryWrapper<UserProjectParticipation>().eq(UserProjectParticipation::getUserId, userId).last("limit 1"));
//    if (userProjectParticipation != null) {
//        userProjectParticipation.setParticipationType(userMetaResponse.getParticipationType());
//        userProjectParticipation.setProjectStatus(userMetaResponse.getProjectStatus());
//        userProjectParticipation.setProjectType(userMetaResponse.getProjectType());
//        userProjectParticipation.setProjectName(userMetaResponse.getProjectName());
//        userProjectParticipationMapper.updateById(userProjectParticipation);
//    }else{
//        //还没有参与项目的记录
//        userProjectParticipation = new UserProjectParticipation();
//        userProjectParticipation.setUserId(userId);
//        userProjectParticipation.setProjectName(userMetaResponse.getProjectName());
//        userProjectParticipation.setParticipationType(userMetaResponse.getParticipationType());
//        userProjectParticipation.setProjectStatus(userMetaResponse.getProjectStatus());
//        userProjectParticipation.setProjectType(userMetaResponse.getProjectType());
//        userProjectParticipationMapper.insert(userProjectParticipation);
//    }
//    int result = userMapper.updateById(user);
//    return result > 0;
//}
//





















